<?php
/**
* Author: Porlock
* Link: www.porlockz.com
* Date: 2018-04-03 15:12:29
* Last Modified time: 
*/
require_once ('includes/lib/func_challenge.php');
require_once ('includes/lib/func_rightCtrl.php');
// 权限控制
player_rightCtrl();
$new_time   = time();
$start_time = mktime(20,0,0,5,11,2018);
$close_time = mktime(22,0,0,5,19,2018);
if ($new_time < $start_time){
	// 未到比赛开始时间，关闭赛题页面
echo <<< EOT
    <script type="text/javascript" src="../layui/layui.all.js"></script>
    <script type="text/javascript">
        layer.msg('比赛即将开始，敬请期待。', {
          icon: 5,
          time: 1500 //2秒关闭（如果不配置，默认是3秒）
        }, function(){
          window.location.href="/afctf/index.php";
        });   
    </script>
EOT;
die();
}
elseif ($new_time > $close_time){
	// 比赛结束后一天，关闭题目页面
echo <<< EOT
    <script type="text/javascript" src="../layui/layui.all.js"></script>
    <script type="text/javascript">
        layer.msg('比赛已结束！', {
          icon: 5,
          time: 1500 //2秒关闭（如果不配置，默认是3秒）
        }, function(){
          window.location.href="/afctf/index.php";
        });   
    </script>
EOT;
die();	
}
// 获取当前用户id
$uid = $_SESSION['uid'];
echo <<< start
<div class="layui-container" style="height:auto; overflow:auto">
start;

$query_web   = "SELECT * FROM `tasks` WHERE `type` = 'Web'";
$query_misc   = "SELECT * FROM `tasks` WHERE `type` = 'Misc'";
$query_reverse   = "SELECT * FROM `tasks` WHERE `type` = 'Reverse'";
$query_crypto   = "SELECT * FROM `tasks` WHERE `type` = 'Crypto'";

//web
challenge($dbh,$query_web,'Web',$uid);
//reserve
challenge($dbh,$query_reverse,'Reverse',$uid);
//misc
challenge($dbh,$query_misc,'Misc',$uid);
//crypto
challenge($dbh,$query_crypto,'Crypto',$uid);


echo <<< end
</div>
<script type="text/javascript" src="layui/layui.all.js"></script>
end;
?>
